package com.yzw.configers;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import redis.clients.jedis.Jedis;

/**
 * @author yzw
 * @date 2022/5/2 10:56
 * @desc redis配置类
 */
@Configuration
public class RedisConfig {
    @Value("${spring.redis.host}")
    private String redisHost;

    @Value("${spring.redis.port}")
    private int redisPort;

    @Value("${spring.redis.password}")
    private String redisPassword;

    @Value("${spring.redis.pool.max-active}")
    private int redisPoolMaxActive;

    @Value("${spring.redis.pool.min-idle}")
    private String redisPoolMinIle;

    @Value("${spring.redis.pool.max-idle}")
    private String redisPoolMaxIdle;

    @Value("${spring.redis.timeout}")
    private String redisTimeout;

    @Bean
    public Jedis init(){
        // 支持多个服务配置 todo   集群有点问题，后续可以看下具体怎么配置
        /*Set<HostAndPort> serverInfo = new HashSet<>();
        serverInfo.add(new HostAndPort(redisHost, redisPort));
        JedisPoolConfig config = new JedisPoolConfig();
        config.setMaxTotal(redisPoolMaxActive);*/
        return new Jedis(redisHost, redisPort, 3000);
    }

}
